<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      let arr = [];
      let adult = [];
      let sum = 0;
      while (arr.length < 5) {
        let num = +prompt(`请输入第${arr.length + 1}年龄`);
        if (num <= 100 && num > 0) {
          arr.push(num);
        }
      }
      let max = [arr[0]];
      let least = [arr[0]];
      for (let i = 0; i < arr.length; i++) {
        if (arr[i] > 18) {
          adult = arr[i];
        }
        if (arr[0] > arr[i]) {
          max = arr[i];
        }
        if (arr[0] < arr[i]) {
          least = arr[i];
        }
        sum += arr[i];
        document.write(`这是成年人的年龄${adult}`);
      }
      let average = sum / arr.length;
      document.write("<br>");
      document.write(sum);
      document.write("<br>");
      document.write(average);
      document.write("<br>");
      document.write(max);
      document.write("<br>");
      document.write(least);
    </script>
  </body>
</html>
